Let the Magellan track reader NOT merge tracks across files.
Magellan track reader names tracks after file read.
# define _CRT_SECURE_NO_DEPRECATE 1
#endif
+/* Pathname separator character */
+#if __WIN32__
+# define GB_PATHSEP '\\'
+#else
+# define GB_PATHSEP '/'
+#endif
+
/*
* Toss in some GNU C-specific voodoo for checking.
*/
void gbser_deinit (void *);
int gbser_read(void *handle, char *ibuf, int sz);
int gbser_setspeed(void *handle, unsigned speed);
+
+#if __WIN32__
+char * fix_win_serial_name(const char *comname);
+#endif
// DCB tio;
COMMTIMEOUTS timeout;
HANDLE comport;
- char *xname= xstrdup("\\\\.\\\\");
+// char *xname= xstrdup("\\\\.\\\\");
+ char *xname = fix_win_serial_name(portname);
gbser_win_handle* handle = xcalloc(1, sizeof(*handle));;
- /* Amazingly, windows will fail the open below unless we
- * prepend \\.\ to the name. It also then fails the open
- * unless we strip the colon from the name. Aaaaargh!
- */
- xname = xstrappend(xname, portname);
- if (xname[strlen(xname)-1] == ':')
- xname[strlen(xname)-1] = 0;
+// /* Amazingly, windows will fail the open below unless we
+// * prepend \\.\ to the name. It also then fails the open
+// * unless we strip the colon from the name. Aaaaargh!
+// */
+// xname = xstrappend(xname, portname);
+// if (xname[strlen(xname)-1] == ':')
+// xname[strlen(xname)-1] = 0;
// xCloseHandle(comport);
comport = CreateFile(xname, GENERIC_READ|GENERIC_WRITE,
gbser_win_handle *h = (gbser_win_handle *) handle;
xfree(h);
}
+
+
+
+
+/*
+ * This isn't part of the above abstraction; it's just a helper for
+ * the other serial modules in the tree.
+ *
+ * Windows does a weird thing with serial ports.
+ * COM ports 1 - 9 are "COM1:" through "COM9:"
+ * The one after that is \\.\\com10 - this function tries to plaster over
+ * that.
+ * It returns a pointer to a staticly allocated buffer and is therefore not
+ * thread safe. The buffer pointed to remains valid only until the next
+ * call to this function.
+ */
+static char gb_com_buffer[100];
+
+char *
+fix_win_serial_name(const char *comname)
+{
+ /* If in the form 'COMx:', use it in place */
+ if ((strlen(comname) == 5) && (comname[4] == ':')) {
+ strcpy(gb_com_buffer, comname);
+ } else {
+ snprintf(gb_com_buffer, sizeof(gb_com_buffer),
+ "\\\\.\\\\%s", comname);
+ if (gb_com_buffer[strlen(gb_com_buffer) - 1 ] == ':') {
+ gb_com_buffer[strlen(gb_com_buffer) - 1] = 0;
+ }
+ }
+ return gb_com_buffer;
+}
DCB tio;
COMMTIMEOUTS timeout;
HANDLE comport;
+ char *xname = fix_win_serial_name(port);
win_serial_data *wsd = xcalloc(sizeof (win_serial_data), 1);
*dh = (gpsdevh*) wsd;
- comport = CreateFile(port, GENERIC_READ|GENERIC_WRITE, 0, NULL,
+ comport = CreateFile(xname, GENERIC_READ|GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (comport == INVALID_HANDLE_VALUE) {
- GPS_Serial_Error("CreateFile on '%s' failed", port);
+ GPS_Serial_Error("CreateFile on '%s' failed", xname);
gps_errno = SERIAL_ERROR;
return 0;
}
static int route_out_count;
static int waypoint_read_count;
static int wpt_len = 8;
+static const char *curfname;
typedef enum {
mrs_handoff = 0,
*/
if (trk_head == NULL) {
trk_head = route_head_alloc();
+ /* These tracks don't have names, so derive one
+ * from input filename.
+ */
+ const char *s = strrchr(curfname, GB_PATHSEP);
+ char *e;
+ if (s) {
+ s++; /* Skip path delim */
+ } else {
+ s = curfname;/* use name intact */
+ }
+
+ /* Whack trailing extension if present. */
+ trk_head->rte_name = xstrdup(s);
+ e = strrchr(trk_head->rte_name, '.');
+ if (e) {
+ *e = '\0';
+ }
+
track_add_head(trk_head);
}
terminit(const char *portname, int create_ok)
{
DCB tio;
- char *xname = xstrdup("\\\\.\\\\");
+// char *xname = xstrdup("\\\\.\\\\");
+ char *xname = fix_win_serial_name(portname);
COMMTIMEOUTS timeout;
is_file = 0;
- xname = xstrappend(xname, portname);
- if (xname[strlen(xname)-1] == ':')
- xname[strlen(xname)-1] = 0;
+// xname = xstrappend(xname, portname);
+// if (xname[strlen(xname)-1] == ':')
+// xname[strlen(xname)-1] = 0;
xCloseHandle(comport);
{
time_t now, later;
waypoint_read_count = 0;
+ curfname = portname;
if (bs) {
bitrate=atoi(bs);
mkshort_del_handle(&mkshort_handle);
waypt_flush(&rte_wpt_tmp);
+
+ trk_head = NULL;
}
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>2004-01-08T20:11:32Z</time>
<trk>
+<name>meridian</name>
<trkseg>
<trkpt lat="30.062183333" lon="-91.610350000">
<ele>1.000000</ele>